
package hackathon.techbooster.tanabata;

public class CharSetting {
    /**
     * 文字
     */
    public final String charcter;

    /**
     * 回転角度
     */
    public final float angle;

    /**
     * xの差分<br />
     * Paint#getFontSpacing() * xが足される<br />
     * -0.5fが設定された場合、1/2文字分左にずれる
     */
    public final float x;

    /**
     * yの差分<br />
     * Paint#getFontSpacing() * yが足される<br />
     * -0.5fが設定された場合、1/2文字分上にずれる
     */
    public final float y;

    /**
     * 文字間のスペース倍率
     */
    public final float space;
    
    public CharSetting(String charcter, float angle, float x, float y, float space) {
        super();
        this.charcter = charcter;
        this.angle = angle;
        this.x = x;
        this.y = y;
        this.space = space;
    }

    public static final CharSetting[] settings = {
            new CharSetting("、", 0.0f, 0.7f, -0.6f, 1.0f), new CharSetting("。", 0.0f, 0.7f, -0.6f, 1.0f),
            new CharSetting("「", 90.0f, -1.0f, -0.3f, 1.0f), new CharSetting("」", 90.0f, -1.0f, 0.0f, 1.0f),
            new CharSetting("（", 90.0f, -1.0f, -0.2f, 1.0f), new CharSetting("）", 90.0f, -1.0f, -0.2f, 1.0f),
            new CharSetting("ぁ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ぃ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ぅ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ぇ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ぉ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("っ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ゃ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ゅ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ょ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ァ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ィ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ゥ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ェ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ォ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ッ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ャ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ュ", 0.0f, 0.1f, -0.1f, 1.0f), new CharSetting("ョ", 0.0f, 0.1f, -0.1f, 1.0f),
            new CharSetting("ー", -90.0f, 0.0f, 0.9f,1.0f), new CharSetting("a", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("b", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("c", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("d", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("e", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("f", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("g", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("h", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("i", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("j", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("k", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("l", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("m", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("n", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("o", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("p", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("q", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("r", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("s", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("t", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("u", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("v", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("w", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("x", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("y", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("z", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("A", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("B", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("C", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("D", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("E", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("F", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("G", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("H", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("I", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("J", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("K", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("L", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("M", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("N", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("O", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("P", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("Q", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("R", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("S", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("T", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("U", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("V", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("W", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("X", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("Y", 90.0f, -1.5f, -0.2f, 0.5f),
            new CharSetting("Z", 90.0f, -1.5f, -0.2f, 0.5f), new CharSetting("ａ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｂ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｃ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｄ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｅ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｆ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｇ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｈ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｉ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｊ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｋ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｌ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｍ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｎ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｏ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｐ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｑ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｒ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｓ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｔ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｕ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｖ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｗ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｘ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("ｙ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("ｚ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ａ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｂ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｃ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｄ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｅ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｆ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｇ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｈ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｉ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｊ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｋ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｌ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｍ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｎ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｏ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｐ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｑ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｒ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｓ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｔ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｕ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｖ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｗ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｘ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("Ｙ", 90.0f, -1.0f, -0.1f, 1.0f),
            new CharSetting("Ｚ", 90.0f, -1.0f, -0.1f, 1.0f), new CharSetting("：", 90.0f, -1.0f, -0.0f,1.0f),
            new CharSetting("；", 90.0f, -1.0f, 0.0f, 1.0f), new CharSetting("／", 90.0f, -1.0f, -0.0f,1.0f),
            new CharSetting("＼", 90.0f, -1.0f, 0.0f, 1.0f), new CharSetting("～", 90.0f, -1.0f, -0.0f,1.0f),
            new CharSetting("゜", 90.0f, -1.0f, 0.0f,1.0f), new CharSetting(" ", 90.0f, 0.0f, 0.0f,0.5f),
            new CharSetting("°", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting(":", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting(";", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("/", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting(".", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("¥", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("_", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("\"", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("$", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("%", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("'", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("…", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("@", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("|", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("^", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("~", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("<", 90.0f, -1.5f, -0.3f, 0.5f), new CharSetting(">", 90.0f, -1.5f, -0.3f, 0.5f),
            new CharSetting("(", 90.0f, -1.5f, -0.3f, 0.5f), new CharSetting(")", 90.0f, -1.5f, -0.3f, 0.5f),
            new CharSetting("{", 90.0f, -1.5f, -0.3f, 0.5f), new CharSetting("}", 90.0f, -1.5f, -0.3f, 0.5f),
            new CharSetting("[", 90.0f, -1.5f, -0.3f, 0.5f), new CharSetting("]", 90.0f, -1.5f, -0.3f, 0.5f),
            new CharSetting("*", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("+", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting(":", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting(";", 90.0f, -1.5f, 0.0f, 0.5f),
            new CharSetting("-", 90.0f, -1.5f, 0.0f, 0.5f), new CharSetting("♡", 0.0f, 0.4f, 0.0f, 0.5f),
            new CharSetting("♥", 0.0f, 0.4f, 0.0f, 0.5f),
            new CharSetting("0", 0.0f, 0.3f, 0.0f, 0.9f), new CharSetting("1", 0.0f, 0.3f, 0.0f, 0.9f),
            new CharSetting("2", 0.0f, 0.3f, 0.0f, 0.9f), new CharSetting("3", 0.0f, 0.3f, 0.0f, 0.9f),
            new CharSetting("4", 0.0f, 0.3f, 0.0f, 0.9f), new CharSetting("5", 0.0f, 0.3f, 0.0f, 0.9f),
            new CharSetting("6", 0.0f, 0.3f, 0.0f, 0.9f), new CharSetting("7", 0.0f, 0.3f, 0.0f, 0.9f),
            new CharSetting("8", 0.0f, 0.3f, 0.0f, 0.9f), new CharSetting("9", 0.0f, 0.3f, 0.0f, 0.9f),
            new CharSetting("!", 0.0f, 0.4f, 0.0f, 0.9f), new CharSetting("?", 0.0f, 0.4f, 0.0f, 0.9f),
    };

    public static CharSetting getSetting(String character) {
        for (int i = 0; i < settings.length; i++) {
            if (settings[i].charcter.equals(character)) {
                return settings[i];
            }
        }
        return null;
    }

    private static final String[] PUNCTUATION_MARK = {
            "、", "。", "「", "」"
    };

    public static boolean isPunctuationMark(String s) {
        for (String functuantionMark : PUNCTUATION_MARK) {
            if (functuantionMark.equals(s)) {
                return true;
            }
        }
        return false;
    }

    public static boolean checkSpecialData(String[] s, int i) {
        // 。が連続して続く場合は。の位置を移動しない
        if (s[i].equals("。")) {
            if (s[i - 1].equals(s[i])) {
                return true;
            } else if (s.length > i + 1) {
                if (s[i].equals(s[i + 1])) {
                    return true;
                }
            }
        }
        return false;
    }

}
